<template>
  <div class="layout">
       <el-container>
        <el-aside width="200px">
          <NavMenu/>
        </el-aside>
        <el-main>
          <el-header>
            <div class="user-info">
              <img class="avatar" src="../../assets/a1.png" alt="">
              <span class="username">{{userInfo.username}}</span>
               <el-dropdown>
                <span class="el-dropdown-link">
                  {{userInfo.username}}<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item >
                    <span @click="logout">退出</span>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
            
           

          </el-header>

          <div class="content">
            <router-view></router-view>
          </div>
        </el-main>
       </el-container>
  </div>
</template>

<script>
import NavMenu from '../views/NavMenu.vue'
import {mapState,mapMutations} from 'vuex'
export default {
    name:'layout',
    components:{NavMenu},
    computed:{
      ...mapState(["userInfo"]),
      // ...mapMutations(['userLogout'])
    },
    methods: {
      logout(){
        this.userLogout()
        this.$router.push('/login')
      },
      ...mapMutations(["userLogout"])
    },
}
</script>

<style scoped>
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    /* text-align: center; */
    /* line-height: 160px; */
  }
  .layout{
    height: 100%;
  }

  .el-container{
    height: 100%;
  }

  .el-header{
      box-shadow: 0 0 5px #ccc;
  }

  .el-main{
    padding: 0px;
  }

  .content{
    padding: 20px;
  }

  .user-info{
    float: right;
    margin-right: 160px;
    margin-top: 10px;
  }
  .avatar{
    width: 30px;
    height: 30px;
  }


</style>